const state = {
  //左侧菜单是否折叠
  isCollapse: JSON.parse(sessionStorage.getItem("isCollapse")) || false,
  //table菜单
  mainTabs: JSON.parse(sessionStorage.getItem("mainTabs")) || [],
  //table激活菜单
  activeTab: JSON.parse(sessionStorage.getItem("mainTabs")) || "",
  //存储路由信息
  routeParams:{}
};
const mutations = {
  SET_COLLAPSE(state) {
    state.isCollapse = !state.isCollapse;
    //持久化存储
    sessionStorage.setItem("isCollapse", JSON.stringify(state.isCollapse));
  },
  //添加tab
  PUSH_MAINTABS(state, value) {
    state.mainTabs.push(value);
    sessionStorage.setItem("mainTabs", JSON.stringify(state.mainTabs));
  },
  //s删除table
  DELETE_MAINTABS(state, value) {
    let index = state.mainTabs.findIndex(item => item.name === value);
    state.mainTabs.splice(index, 1);
    sessionStorage.setItem("mainTabs", JSON.stringify(state.mainTabs));
  },
  //清空table
  CLEAR_MAINTABS(state){
    state.mainTabs = [];
    sessionStorage.setItem("mainTabs", JSON.stringify([]));
  },
  //设置当前激活路由
  SET_ACTIVETAB(state, value) {
    state.activeTab = value;
    sessionStorage.setItem("activeTab", JSON.stringify(state.activeTab));
  },
  SET_ROUTEPARAMES(state,value){
    
  }
};
const actions = {};
export default {
  state,
  mutations,
  actions
};
